/*
 * PublicChatMessage.java
 *
 * Created on 29 de Junho de 2005, 14:40
 */

package jhub.text;
import java.text.*;

import jhub.DCProtocol;
import jhub.UserSession;
/**
 *
 * @author  botelhodaniel
 */
public class PublicChatMessage extends DCRawCommand{
    
    public static PublicChatMessage getInstance(String sender, String message) throws ParseException{
        return new PublicChatMessage(MessageFormat.format(DCProtocol.PUBLIC_CHAT_FORMAT,sender,message));
    }
    
    private String message;
    private String nick;
    
    /** Creates a new instance of PublicChatMessage */
    public PublicChatMessage(String raw) throws ParseException{
        super(raw);
        parse();
    }
    
    private void parse() throws ParseException{
        Object[] o = new MessageFormat(DCProtocol.PUBLIC_CHAT_FORMAT).parse(command.toString());
        nick = o[0].toString();
        message = o[1].toString();
    }
    
    public String getNick(){
        return nick;
    }
    
    public String getMessage(){
        return message;
    }
    
}
